package cn.tedu._05mvcboot4.common.response;

import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class JsonResult {
    @ApiModelProperty(value = "状态码",required = true)
    private Integer status;
    @ApiModelProperty(value = "状态信息",required = true)
    private String message;
    @ApiModelProperty(value = "数据",required = true)
    private Object data;

    public JsonResult(StatusCode statusCode){
        this.status = statusCode.getStatus();
        this.message = statusCode.getMessage();
    }

    public JsonResult(StatusCode statusCode, Object data){
        this.status = statusCode.getStatus();
        this.message = statusCode.getMessage();
        this.data = data;
    }

    public static JsonResult ok(){
        return new JsonResult(StatusCode.OPERATION_SUCCESS);
    }

    public static JsonResult ok(Object data){
        return new JsonResult(StatusCode.OPERATION_SUCCESS,data);
    }
}
